{
  LW Txtred -- LightWave Surface Editor

  This global provides access to a user interface for editing textures.
  If you use XPanels with vparms that can be textured, the interaction
  with the texture editor is handled for you, and you don't need this global.
  But if your interface is built with classic Panels or OS-specific elements,
  you can use this global to provide your users with the standard texture interface.

  Based on lwtxtred.h which is:
  Copyright 1999, NewTek, Inc.
}

{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit LW_Txtred;

{$mode objfpc}{$H+}

interface

uses
  LW_Types ,
  LW_Txtr  ;

const
  LWTXTREDFUNCS_GLOBAL = 'Texture Editor 2' ;

  { Editor Flags }
  TEF_USEBTN	= 1 shl 0 ;	// adds use/remove buttons at the bottom of the pane.
  TEF_OPACITY	= 1 shl 1 ;	// adds layer opacity settings
  TEF_BLEND	= 1 shl 2 ;	// adds blend options to the layer global settings
  TEF_TYPE	= 1 shl 3 ;	// adds layer type control on top of pane.
  TEF_LAYERS	= 1 shl 4 ;	// adds layer list pane on left side of the pane.
  TEF_ALL	= 31 ;  	// standard set of flags for the texture editor

  { Event Codes passed to the event callback }
  TXEV_ALTER	= 1 ;
  TXEV_TRACK	= 2 ;
  TXEV_DELETE	= 4 ;

type
  { Clients can edit textures by subscribing to the texture editor services.
    The subscription returns an identifier this identifier holds information
    about the client, some UI flags, etc, that are used in function calls. }
  PLWTEClt = ^TLWTEClt ;
  TLWTEClt = record end ;

  { Clients can set call backs for the 'Remove Texture',
    and the 'Automatic Sizing' buttons.
    For the AutoSize call back, the client needs to fill in bbox
    with the corners of the texture's bounding box:
    bbox[][0] = min[],  bbox[][1] = max[]                         }
  TLWTxtrRemoveFunc   = procedure
                        (       TextureID   :  PLWTexture   ;
                                UserData    :  Pointer      ) ;
  TLWTxtrAutoSizeFunc = function
                        (       TextureID   :  PLWTexture   ;
                                UserData    :  Pointer      ;
                                BBox        :  array {[0..2][0..1]} of Double ) : Integer ;
  TLWTxtrEventFunc    = function
                        (       TextureID   :  PLWTexture   ;
                                UserData    :  Pointer      ;
                                EventCode   :  Integer      ) : Integer ;
  TLWGradAutoSizeFunc = function
                        (       Param       :  PLWTxtrParamDesc ;
                                ParamNumber :  Integer          ;
                                UserData    :  Pointer          ) : Integer ;

  PLWTxtrEdFuncs = ^TLWTxtrEdFuncs ;
  TLWTxtrEdFuncs = record
    Subscribe           : function
                          (       Title            : PChar               ;
                                  Flags            : Integer             ;
                                  UserData         : Pointer             ;
                                  TxtrRemoveFunc   : TLWTxtrRemoveFunc   ;
                                  TxtrAutoSizeFunc : TLWTxtrAutoSizeFunc ;
                                  TxtrEventFunc    : TLWTxtrEventFunc    ): PLWTEClt ;
    Unsubscribe         : procedure
                          (       TEdClient        : PLWTEClt            ) ;
    Open                : procedure
                          (       TEdClient        : PLWTEClt            ;
                                  TextureID        : PLWTexture          ;
                                  Title            : PChar               ) ;
    SetTexture          : procedure
                          (       TEdClient        : PLWTEClt            ;
                                  TextureID        : PLWTexture          ;
                                  Title            : PChar               ) ;
    SetPosition         : procedure
                          (       TEdClient        : PLWTEClt            ;
                                  X                ,
                                  Y                : Integer             ) ;
    Close               : procedure
                          (       TEdClient        : PLWTEClt            ) ;
    IsOpen              : function
                          (       TEdClient        : PLWTEClt            ) : Integer   ;
    // Forces editor refresh
    Refresh             : function
                          (       TEdClient        : PLWTEClt            ) : Integer   ;
    // Returns currently selected texture layer
    CurrentLayer        : function
                          (       TEdClient        : PLWTEClt            ) : PLWTLayer ;
    // Adds texture to multiselection
    SelectAdd           : function
                          (       TEdClient        : PLWTEClt            ;
                                  TextureID        : PLWTexture          ) : Integer   ;
    // Removes texture from multiselection
    SelectRem           : function
                          (       TEdClient        : PLWTEClt            ;
                                  TextureID        : PLWTexture          ) : Integer    ;
    // Clears multiselection
    SelectClr           : function
                          (       TEdClient        : PLWTEClt            ) : Integer    ;
    // Returns first texture in the selection
    SelectFirst         : function
                          (       TEdClient        : PLWTEClt            ) : PLWTexture ;
    // Returns next texture in the selection
    SelectNext          : function
                          (       TEdClient        : PLWTEClt            ;
                                  TextureID        : PLWTexture          ) : PLWTexture ;
    SetGradientAutoSize : procedure
                          (       TEdClient        : PLWTEClt            ;
                                  GradAutoSizeFunc : TLWGradAutoSizeFunc ) ;
  end;

implementation

end.

